package edu.pitt.cs.cs2410pj2.datamodel;

import java.util.ArrayList;

/**
 * Directory item
 * 
 * @author zhangfan
 * 
 */
public class DirectoryEntry {
	private int state = State.INVALID;
	private boolean busy = false; //For sequential writes
	private String blockAddr;
	private ArrayList<Integer> owners = new ArrayList<Integer>();
	
	public void addOwner(int tileId) {
		owners.add(tileId);
	}
	
	public void clearOwners() {
		this.owners.clear();
	}
	
	public void removeOwner(int tileId) {
		for(int i = 0;i<owners.size();i++) {
			if(owners.get(i)==tileId) {
				owners.remove(i);
				return;
			}
		}
	}
	
	public ArrayList<Integer> getOwners() {
		return this.owners;
	}
	
	public boolean isBusy() {
		return busy;
	}
	
	public void setBusy(boolean busy) {
		this.busy = busy;
	}
	
	public int getState() {
		return state;
	}

	public void setState(int state) {
		this.state = state;
	}

	public String getBlockAddr() {
		return blockAddr;
	}

	public void setBlockAddr(String blockAddr) {
		this.blockAddr = blockAddr;
	}

}
